<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>实验室设备管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../static/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style>
    th
    {
      text-align: center !important;
    }
    </style>
</head>
<body style="height: 600px">

<table class="layui-table" id="test" >
<!-- lay-data="{width: 892, height:332, url:'/demo/table/user/', page:true, id:'idTest'}" lay-filter="demo" -->
  <thead>
    <tr>
      <th lay-data="{width:80, sort: true, fixed: left}">序号</th>
      <th lay-data="{width:80, sort: true}">设备名称</th>
      <th lay-data="{width:80}">设备型号</th>
      <th lay-data="{width:80, sort: true}">负责教师</th>
      <th lay-data="{width:80}">教师电话</th>
      <th lay-data="{width:40}">质保期</th>
      <th lay-data="{width:140}">安装地点</th>
      <th lay-data="{fixed:'right', width:178, toolbar: '#barDemo'}">操作</th>
    </tr>
  </thead>
  <tbody>
    {% block table %}
    {% for equipment in equipments %}
    <tr>
      <td align="center">
        <div class="layui-table-cell">{{ forloop.counter }}</div>
    </td>
    <td align="center">
        <div class="layui-table-cell">{{ equipment.eName }}</div>
    </td>
    <td align="center">
      <div class="layui-table-cell">{{ equipment.eModel }}</div>
    </td>
    <td align="center">
        <div class="layui-table-cell">{{ equipment.eDirector.userName }}</div>
    </td>
    <td align="center">
        <div class="layui-table-cell">{{ equipment.eDirector.userPhone }}</div>
    </td>
    <td align="center">
        <div class="layui-table-cell">{{ equipment.eWarranty|date:"Y-m-d" }}</div>
    </td>
    <td align="center">
        <div class="layui-table-cell">{{ equipment.eLocation }}</div>
    </td>
    <td align="center">
      <div class="layui-table-cell">
        <a class="edit layui-btn layui-btn-xs" lay-event="edit" data-url=/teacher/edit-equipment?eid={{equipment.id}}><i class="layui-icon"></i></a>
        <a class="del layui-btn layui-btn-danger layui-btn-xs" lay-event="del"  data-url=/teacher/delete-equipment?eid={{equipment.id}}><i class="layui-icon"></i></a>
      </div>
    </td>
    </tr>
    {% endfor %}
    {% endblock %}
  </tbody>

</table>

<script src="../../static/layui/layui.js" type="text/javascript"></script>
<script src="../../static/layui/lay/modules/jquery.js" type="text/javascript"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript">

  layui.use('layer', function(){
    var layer = layui.layer;
    var $ = layui.jquery;
    $(".del").click(function() {
      var url = $(this).attr("data-url");
      $.get(url,function(data,status){
        console.log(layer);
        layer.msg(data, {time: 1000}, function() {
          location.href = location.href;
        });
      });
    });

  });

</script>

<script type="text/javascript">
layui.use('layer', function(){
    var layer = layui.layer;
    var $ = layui.jquery;
    $(".edit").click(function() {
      var url = $(this).attr("data-url");
     layer.open({
                type: 2 //此处以iframe举例
                , title: '更新设备信息'
                , area: ['700px', '400px']
                , shade: 0
                , maxmin: true
                , offset: '10px'
                , content: url
                , btn: ['关闭'] //只是为了演示
                , end: function () {
                location.reload();}
            });
    });
});

</script>
</body>
</html>